/*
 * Copyright 2009 Eat Local Food, LLC
 *
 * This file is part of gwtCommerce.
 *
 * gwtCommerce is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * gwtCommerce is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gwtCommerce.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.elf.gwt.admin.client.subcomponents;

import com.elf.gwt.admin.client.AdminComponentController;
import com.elf.gwt.admin.client.components.AccountComponent;
import com.elf.gwt.admin.client.components.CurrenciesAdministrationComponent;
import com.elf.gwt.admin.client.components.LanguagesAdministrationComponent;
import com.elf.gwt.common.client.callback.SubComponentCallback;
import com.elf.gwt.common.client.subcomponent.CommonSubComponent;
import com.elf.gwt.common.client.utils.CommonUtils;

/**
 *  Provides for common behavior of subcomponents.
 */
public class AdminSubComponent extends CommonSubComponent
{
	/** master controller for application **/
	protected AdminComponentController controller;

	protected static AccountComponent accountComponent = null;
	protected static CurrenciesAdministrationComponent currenciesAdministrationComponent = null;
	protected static LanguagesAdministrationComponent languagesAdministrationComponent = null;
	
	/**
	 * Constructor
	 */
	public AdminSubComponent(AdminComponentController controller, String handle, String superAction, SubComponentCallback callback)
	{
		super(handle, superAction, callback);
		this.controller = controller;
	}

	public String getImageCommonDirectory()
	{
		if (languagesAdministrationComponent == null) languagesAdministrationComponent = (LanguagesAdministrationComponent)controller.getComponent("LanguagesAdministrationComponent");
		return CommonUtils.getImageCommonDirectory() + languagesAdministrationComponent.getLanguageModel().getCode() + "/";
	}
	
	public String getImageDirectory()
	{
		if (languagesAdministrationComponent == null) languagesAdministrationComponent = (LanguagesAdministrationComponent)controller.getComponent("LanguagesAdministrationComponent");
		return CommonUtils.getImageDirectory() + getHandle() + "/" + languagesAdministrationComponent.getLanguageModel().getCode() + "/";
	}
	
	public AdminComponentController getController() {
		return controller;
	}
}
